package com.jn.dagger.views;

import android.util.Log;

import com.jn.dagger.R;
import com.jn.dagger.base.BaseActivity;
import com.jn.dagger.component.DaggerAllComponent;
import com.jn.dagger.database.DBHelper;
import com.jn.dagger.module.DBModule;
import com.jn.dagger.module.SpUtilsModule;
import com.jn.dagger.module.StudentModule;
import com.jn.dagger.utils.SpUtils;

import java.util.List;

import jakarta.inject.Inject;

public class InfoActivity extends BaseActivity {

    @Inject
    public DBHelper mDBHelper;

    @Inject
    public SpUtils mSpUtils;

    @Override
    public int getLayoutId() {
        return R.layout.activity_info;
    }

    @Override
    public void init() {
        DaggerAllComponent
                .builder()
                .studentModule(new StudentModule())
                .dBModule(new DBModule(this))
                .spUtilsModule(new SpUtilsModule(this))
                .build()
                .injectInfoActivity(this);

        // 获取课程
        List<String> courses = mDBHelper.selectAllCourses();
        for (String course : courses) {
            Log.d("InfoActivity", course);
        }

        // 获取数据
        String value = mSpUtils.getString("key");
        Log.d("InfoActivity", "获取到的值: " + value);
    }
}
